<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>哈哈</li>
        <li>哈哈</li>
        <li>哈哈</li>
        <li>哈哈</li>
        <li>哈哈</li>
        <p>heihei </p>
    </ul>
    <script>
        const ul = document.querySelector('ul')
        ul.addEventListener('click', function (e) {
            if (e.target.tagName === 'LI') {//如果目标的名字是li
                e.target.style.color = 'red'
            }
        })
    </script>
</body>

</html>